//
//  FinAuthCameraConfig.h
//  FinAuthBaseKit
//
//  Created by FinAuthDev on 2024/5/18.
//  Copyright © 2024年 FinAuth. All rights reserved.
//

#ifndef FinAuthCameraConfig_h
#define FinAuthCameraConfig_h

#import <UIKit/UIKit.h>

/* 屏幕宽度 （区别于viewcontroller.view.fream）*/
#define FinAuthWIN_WIDTH  [UIScreen mainScreen].bounds.size.width

/* 屏幕高度 （区别于viewcontroller.view.fream）*/
#define FinAuthWIN_HEIGHT [UIScreen mainScreen].bounds.size.height

/* 手机系统版本 */
#define FinAuthIOS_SysVersion [[UIDevice currentDevice] systemVersion].floatValue

/* rgb颜色转换（16进制->10进制）*/
#define FinAuthColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

/* rgba颜色 */
#define FinAuthColorWithRGB(R, G, B, A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A]

/* 判断是否为 iPhone X */
#define IS_IPHONE_X  \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) { \
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
} else {\
if (@available(iOS 13.0, *)) {\
NSArray* array = [[UIApplication sharedApplication].connectedScenes allObjects];\
if (array) {\
UIWindowScene* windowScene = (UIWindowScene *)array[0];\
UIWindow* mainWindow = [windowScene valueForKeyPath:@"delegate.window"];\
isPhoneX = mainWindow.safeAreaInsets.bottom > 0.0;\
}\
}\
}\
}\
(isPhoneX);})

#ifdef DEBUG
#define FinAuthLog(...)
#else
#define FinAuthLog(...)
#endif

#endif /* FinAuthCameraConfig_h */
